<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>后台管理系统</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="/dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. We have chosen the skin-blue for this starter
    page. However, you can choose any other skin. Make sure you
    apply the skin class to the body tag so the changes take effect.
    -->
    <link rel="stylesheet" href="/dist/css/skins/skin-blue.min.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- bootstrap datepicker -->
    <link rel="stylesheet" href="/plugins/datepicker/datepicker3.css">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<#include "header.ftl" />
<#include "sidebar.ftl" />
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper" id="app">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                客户管理
                <small>合同列表</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 客户管理</a></li>
                <li class="active">合同列表</li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="invoice">
            <!-- info row -->
            <div class="row invoice-info">
                <div class="col-sm-6 invoice-col">
                    <b>客户信息</b><br>
                    <br>
                    <b>姓名:</b> ${(customer.name)!}<br>
                    <b>注册手机号:</b> ${(customer.cellPhoneNum)!}<br>
                </div>
                <!-- /.col -->
                <div class="col-sm-6 invoice-col">
                    <b>合同信息</b><br>
                    <br>
                    <b>合同ID:</b> ${(contract.id)!}<br>
                    <b>房东姓名:</b> ${(contract.landlord)!}<br>
                    <b>房东手机号:</b> ${(contract.cellphone)!}<br>
                    <b>房东开户行:</b> ${(contract.bank)!}<br>
                    <b>房东账号:</b> ${(contract.account)!}
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->

            <!-- Photo row -->
            <div class="row">
                <div class="col-xs-4">
                    <div class="thumbnail">
                    <#if (contract.photo1Url)??>
                        <img src="/files/${contract.photo1Url!}" style="height: 710px; width: 100%; display: block;" alt="合同照片">
                    <#else>
                        <img src="/images/null.png" style="height: 710px; width: 100%; display: block;" alt="合同照片">
                    </#if>
                    </div>
                </div>
                <div class="col-xs-4">
                    <div class="thumbnail">
                    <#if (contract.photo2Url)??>
                        <img src="/files/${contract.photo2Url!}" style="height: 710px; width: 100%; display: block;" alt="合同照片">
                    <#else>
                        <img src="/images/null.png" style="height: 710px; width: 100%; display: block;" alt="合同照片">
                    </#if>
                    </div>
                </div>
                <div class="col-xs-4">
                    <div class="thumbnail">
                    <#if (contract.photo3Url)??>
                        <img src="/files/${contract.photo3Url!}" style="height: 710px; width: 100%; display: block;" alt="合同照片">
                    <#else>
                        <img src="/images/null.png" style="height: 710px; width: 100%; display: block;" alt="合同照片">
                    </#if>
                    </div>
                </div>
            </div>
            <!-- /.row -->

            <!-- Form row -->
            <div class="row">
                <form id="contract" method="post" action="/contracts/update">
                    <input type="hidden" id="contractId" name="contractId" value="${contract.id}" />
                    <div id="date">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">合同起始日:</label>
                            <div class="col-sm-5 input-group date">
                                <div class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </div>
                                <input form="contract" value="${contract.startDate!}" type="text" data-date-format="yyyy-mm-dd" class="form-control pull-right" name="startDate" id="startDate">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">合同结束日:</label>
                            <div class="col-sm-5 input-group date">
                                <div class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </div>
                                <input form="contract" value="${contract.endDate!}" type="text" data-date-format="yyyy-mm-dd" class="form-control pull-right" name="endDate" id="endDate">
                            </div>
                        </div>
                    </div>
                    <div id="address">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">租房城市:</label>
                            <div class="col-sm-10">
                                <label for="province"></label>
                                <select id="province" name="province" form="contract"></select>
                                <label for="city"></label>
                                <select id="city" name="city" form="contract"></select>
                                <label for="area"></label>
                                <select id="area" name="area" form="contract"></select>
                                <label for="town">${(contract.address.street)!''}</label>
                                <select id="town" name="town" form="contract"></select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="addressInfo" class="col-sm-2 control-label">详细地址:</label>
                            <div class="col-sm-10">
                                <input id="addressInfo" name="addressInfo" class="form-control" form="contract" type="text" value="${(contract.address.addressInfo)!''}">
                            </div>
                        </div>
                    </div>
                    <div id="contractStatus">
                        <label for="status" class="col-sm-2 control-label">合同状态:</label>
                        <div class="col-sm-10">
                            <select name="status" id="status" form="contract" value="${contract.status!''}">
                                <option value="Init" <#if (((contract.status)!'') == 'Init')>selected="selected"</#if> > 待补全 </option>
                                <option value="PoorPhoto" <#if (((contract.status)!'') == 'PoorPhoto')>selected="selected"</#if> > 照片模糊 </option>
                                <option value="TooManyTimes" <#if (((contract.status)!'') == 'TooManyTimes')>selected="selected"</#if> > 房东频繁收款 </option>
                                <option value="WrongInfo" <#if (((contract.status)!'') == 'WrongInfo')>selected="selected"</#if> > 房东与合同信息不符 </option>
                                <option value="Verified" <#if (((contract.status)!'') == 'Verified')>selected="selected"</#if> > 已补全 </option>
                            </select>
                        </div>
                    </div>
                    <p class="pull-right">
                        <input type="submit" class="btn btn-danger btn-lg" value="确认并返回" />
                        <a href="/contracts" class="btn btn-info btn-lg" role="button">返回</a>
                    </p>
                </form>
            </div>
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

<#include "footer.ftl" />
</div>
<!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->

<!-- jQuery 2.2.0 -->
<script src="/plugins/jQuery/jQuery-2.2.0.min.js"></script>
<!-- Bootstrap 3.3.6 -->
<script src="/bootstrap/js/bootstrap.min.js"></script>
<!-- bootstrap datepicker -->
<script src="/plugins/datepicker/bootstrap-datepicker.js"></script>
<script src="/plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<!-- AdminLTE App -->
<script src="/dist/js/app.min.js"></script>
<!-- 省市区街道选择控件 -->
<script src="/js/jquery.citys.js"></script>
<script type="text/javascript">
    //Date picker
    $('#startDate').datepicker({
        language: 'zh-CN',
        autoclose: true,
        todayHighlight: true
    });
    $('#endDate').datepicker({
        language: 'zh-CN',
        autoclose: true,
        todayHighlight: true
    });
    var $town = $('#address select[name="town"]');
    var townFormat = function(info){
        $town.hide().empty();
        if(info['code']%1e4&&info['code']<7e6){	//是否为“区”且不是港澳台地区
            $.ajax({
                url:'http://passer-by.com/data_location/town/'+info['code']+'.json',
                dataType:'json',
                success:function(town){
                    $town.show();
                    for(i in town){
                        $town.append('<option value="'+i+'">'+town[i]+'</option>');
                    }
                }
            });
        }
    };
    $('#address').citys({
        province:'${(contract.address.province)!''}',
        city:'${(contract.address.city)!''}',
        area:'${(contract.address.area)!''}',
        onChange:function(info){
            townFormat(info);
        }
    },function(api){
        var info = api.getInfo();
        townFormat(info);
    });
</script>

</body>
</html>